﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="EditBranch.aspx.cs" Inherits="EditBranch" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language="JavaScript">
function onlyNumbers(evt)
{
	var e = event || evt; // for trans-browser compatibility
	var charCode = e.which || e.keyCode;

	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	return true;

}
</script>
 <table width="100%">
  <tr>
    <td class="header">Edit Branch Information</td>
  </tr>
  <br />
  </table>
    <asp:FormView ID="frmEditService" runat="server" BackColor="#DEBA84" 
          BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
          CellSpacing="2" GridLines="Both" 
          Width="500px" DataSourceID="ObjectDataSourceEditBranch" 
        onitemcommand="frmEditService_ItemCommand">
        <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
        <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
        <ItemTemplate>
        <div>
         <table class="table01" width="100%">
            <tr>
                <td width="20%">
                    <b>
                        <asp:Label ID="lblPinCode" runat="server" Text="Pincode"></asp:Label></b>
                </td>
                <td width="40%">
                    <asp:TextBox ID="txtPincode" runat="server" Width="200px" 
                        onkeypress="return onlyNumbers();" Enabled="False" 
                        Text='<%# Bind("PinCode") %>' ></asp:TextBox>
                        
                </td>
            </tr>
            <tr>
                <td width="20%">
                    <b>
                        <asp:Label ID="lblBranchName" runat="server" >Branch's Name</asp:Label></b>
                </td>
                <td width="40%">
                    <asp:TextBox ID="txtBranchName" runat="server" Width="200px" Enabled="False" 
                        Text='<%# Bind("BranchName") %>'></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td width="20%">
                    <b>
                        <asp:Label ID="lblBranchAddress" runat="server" Text="Branch's Address"></asp:Label></b>
                </td>
                <td width="40%">
                    <asp:TextBox ID="txtBranchAddress" runat="server" Width="200px" 
                        TextMode="MultiLine" Height="50px" Enabled="False" 
                        Text='<%# Bind("BranchAddress") %>'></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td width="20%">
                    <b>Branch's Mobile Phone</b>
                </td>
                <td width="40%">
                    <asp:TextBox ID="txtBranchPhone" runat="server" Width="200px" 
                        onkeypress="return onlyNumbers();" Enabled="False" 
                        Text='<%# Bind("BranchPhone") %>'></asp:TextBox>
                    <br />
                    <asp:Label ID="lblPhoneNumberInstruction" runat="server" Text="Ex: 08438487771"></asp:Label>
                </td>
            </tr>
            <tr>
                <td width="20%">
                    <b>Branch's Fax</b>
                </td>
                <td width="40%">
                    <asp:TextBox ID="txtFax" runat="server" Width="200px" 
                        onkeypress="return onlyNumbers();" Enabled="False" 
                        Text='<%# Bind("BranchFax") %>'></asp:TextBox>
                    <br />
                    <asp:Label ID="lblFaxNumberInstruction" runat="server" Text="Ex:9990123456"></asp:Label>
                </td>
            </tr>
            <tr>
                <td width="20%">
                    <b>City Name</b>
                </td>
                <td width="40%">
                    <asp:DropDownList ID="ddlCityName" runat="server" DataSourceID="ObjectDataSourceCity"
                        DataTextField="CityName" DataValueField="CityID"  Enabled="false"
                        ValidationGroup="AddBranch" SelectedValue='<%# Bind("CityID") %>'>
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="ObjectDataSourceCity" runat="server" 
                        OldValuesParameterFormatString="original_{0}" SelectMethod="ListCity" 
                        TypeName="DALCity">
                    </asp:ObjectDataSource>
                </td>
            </tr>
            
             <tr>
                 <td width="20%">
                     <asp:Button ID="cmdEdit" runat="server" Text="Edit" CommandName="Edit" />
                 </td>
                 <td width="40%">
                     &nbsp;</td>
             </tr>
            
        </table></div>
        </ItemTemplate>
   <EditItemTemplate>
   <div>
     
        <table class="table01" width="100%">
            <tr>
                <td width="20%">
                    <b>
                        <asp:Label ID="lblPinCode" runat="server" Text="Pincode"></asp:Label></b>
                </td>
                <td width="40%">
                    <asp:TextBox ID="txtPincode" runat="server" Width="200px" onkeypress="return onlyNumbers();"
                        ValidationGroup="AddBranch" Text='<%# Bind("PinCode") %>' ></asp:TextBox>
                    <asp:RequiredFieldValidator ID="valPinCode" runat="server" ErrorMessage="Please pincode of branch"
                        ControlToValidate="txtPincode" ValidationGroup="AddBranch">*</asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionPincode" runat="server" ErrorMessage="Pincode is not valid"
                        ControlToValidate="txtPincode" ValidationGroup="AddBranch" ValidationExpression="\d{6}">*</asp:RegularExpressionValidator>
                        
                </td>
            </tr>
            <tr>
                <td width="20%">
                    <b>
                        <asp:Label ID="lblBranchName" runat="server" ></asp:Label></b>
                </td>
                <td width="40%">
                    <asp:TextBox ID="txtBranchName" runat="server" Width="200px" 
                        ValidationGroup="AddBranch" Text='<%# Bind("BranchName") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="valBranchName" runat="server" ErrorMessage="Please enter name of branch"
                        ValidationGroup="AddBranch" ControlToValidate="txtBranchName">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td width="20%">
                    <b>
                        <asp:Label ID="lblBranchAddress" runat="server" Text="Branch's Address"></asp:Label></b>
                </td>
                <td width="40%">
                    <asp:TextBox ID="txtBranchAddress" runat="server" Width="200px" 
                        TextMode="MultiLine" Height="50px" ValidationGroup="AddBranch" 
                        Text='<%# Bind("BranchAddress") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="valBranchAddress" runat="server" ErrorMessage="Please enter address of branch"
                        ValidationGroup="AddBranch" ControlToValidate="txtBranchAddress">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td width="20%">
                    <b>Branch's Mobile Phone</b>
                </td>
                <td width="40%">
                    <asp:TextBox ID="txtBranchPhone" runat="server" Width="200px" onkeypress="return onlyNumbers();"
                        ValidationGroup="AddBranch" Text='<%# Bind("BranchPhone") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="valBranchPhone" runat="server" ErrorMessage="Please enter branch's phone number"
                        ValidationGroup="AddBranch" ControlToValidate="txtBranchPhone">*</asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionMobilePhone" runat="server"
                        ControlToValidate="txtBranchPhone" ErrorMessage="Phone number must be between 9-20 digits"
                        Text="*" ValidationGroup="AddBranch" ValidationExpression="\d{9,20}"></asp:RegularExpressionValidator>
                    <br />
                    <asp:Label ID="lblPhoneNumberInstruction" runat="server" Text="Ex: 08438487771"></asp:Label>
                </td>
            </tr>
            <tr>
                <td width="20%">
                    <b>Branch's Fax</b>
                </td>
                <td width="40%">
                    <asp:TextBox ID="txtFax" runat="server" Width="200px" 
                        ValidationGroup="AddBranch" onkeypress="return onlyNumbers();" 
                        Text='<%# Bind("BranchFax") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="valFax" runat="server" ErrorMessage="Please enter branch's fax number"
                        ValidationGroup="AddBranch" ControlToValidate="txtFax">*</asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionFax" runat="server" ControlToValidate="txtFax"
                        ErrorMessage="Fax number must be between 9-20 digits" Text="*" ValidationGroup="AddBranch"
                        ValidationExpression="\d{9,20}"></asp:RegularExpressionValidator>
                    <br />
                    <asp:Label ID="lblFaxNumberInstruction" runat="server" Text="Ex:9990123456"></asp:Label>
                </td>
            </tr>
            <tr>
                <td width="20%">
                    <b>City Name</b>
                </td>
                <td width="40%">
                    <asp:DropDownList ID="ddlCityName" runat="server" DataSourceID="ObjectDataSourceCity"
                        DataTextField="CityName" DataValueField="CityID" 
                        ValidationGroup="AddBranch" SelectedValue='<%# Bind("CityID") %>'>
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="ObjectDataSourceCity" runat="server" 
                        OldValuesParameterFormatString="original_{0}" SelectMethod="ListCity" 
                        TypeName="DALCity">
                    </asp:ObjectDataSource>
                    <br />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false"  CommandName="Cancel"/>
                    <asp:Button ID="btnUpdate" runat="server" Text="Update" ValidationGroup="AddBranch" CommandName="Update" />
                </td>
            </tr>
            
            <tr>
                <td colspan="2">
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server"  ValidationGroup="AddBranch"/></td>
            </tr>
            
        </table>
      
       
    </div>
    </EditItemTemplate>
        <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
    </asp:FormView>
    <asp:ObjectDataSource ID="ObjectDataSourceEditBranch" runat="server" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="SelectedBranch" 
        TypeName="DALBranch" UpdateMethod="UpdateBranch">
        <UpdateParameters>
            <asp:Parameter Name="PinCode" Type="String" />
            <asp:Parameter Name="BranchAddress" Type="String" />
            <asp:Parameter Name="BranchName" Type="String" />
            <asp:Parameter Name="BranchFax" Type="String" />
            <asp:Parameter Name="BranchPhone" Type="String" />
            <asp:Parameter Name="CityID" Type="String" />
        </UpdateParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="PinCode" QueryStringField="PinCode" 
                Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:Label ID="lblMessage" runat="server"></asp:Label>
    <br />
</asp:Content>


